function setupExpertExportGrid() {
    $("#expertSearch").jqGrid({
        url : 'getExpertSearchtList.action',
        datatype : "local",
        colNames : [ '序号','专家类别', '姓名', '性别', '出生日期', '最高学历', '单位', '职位', '手机', '邮箱地址', '调用次数', '', '' ],
        colModel : [{ name : 'no', index : 'no', width : 25, sortable: false }, 
                    { name : 'categoryId', index : 'categoryId', width : 80},
                    { name : 'name', index : 'name', width : 60 },
                    { name : 'isMale', index : 'isMale', width : 30 }, 
                    { name : 'birthday', index : 'birthday', width : 80 },
                    { name : 'topEducation', index : 'topEducation', width : 60 },
                    { name : 'workUnit', index : 'workUnit', width : 100 },
                    { name : 'post', index : 'post', width : 60 },
                    { name : 'cellPhone', index : 'cellPhone', width : 90 },
                    { name : 'mailAddress', index : 'mailAddress', width : 100 },
                    { name : 'callTimes', index : 'callTimes', width : 60 },
                    { name : 'callHistory', index : 'callHistory', width : 65, sortable: false },
                    { name : 'expertDetail', index : 'expertDetail', width : 65, sortable: false }],
        rowNum : 10,
        height : 'auto',
        rowList : [ 10, 20, 30 ],
        pager : '#pager',
        sortname : 'id',
        viewrecords : true,
        sortorder : "desc",
        caption : "专家信息一览",
        gridComplete : function() {
            var ids = $('#expertSearch').jqGrid('getDataIDs');
            for (var i = 0; i < ids.length; i++) {
                var id = ids[i];
                $('#expertSearch').jqGrid('setRowData', id, {
                    callHistory : "<button class='gridBtn' onclick='toHistory(" + id + ");'>调用履历</button>",
                    expertDetail : "<button class='gridBtn' onclick='toDetail(" + id + ");'>专家详细</button>"
                });
            }
        },
        multiselect : false,
        loadError : dealError
    });
    $("#expertSearch").jqGrid('navGrid', '#pager', {
        edit : false,
        add : false,
        del : false
    });
}

function setupExpertExportToolbar() {
    $("#search").button({
        icons : {
            primary : "ui-icon-search"
        }
    }).click(function() {
        $("#detail").dialog("open");
    });

    $("#keywordMatch").button({
        icons : {
            primary : "ui-icon-search"
        }
    }).click(function() {
        $("#keywordDetail").dialog("open");
    });

    $("#export").button({
        icons : {
            primary: "ui-icon-copy"
        }
    }).click(function() {
        $("#expertDetail").submit();
    });
}

function setupExpertExportDialog() {
    $("#detail").dialog({
        autoOpen : false,
        show : "slide",
        height : 600,
        width : 600,
        modal : true,
        buttons : {
            检索 : function() {
                var expertSearch = {
                    'expertSearch.idNo' : $("#idNo").val(),
                    'expertSearch.name' : $("#name").val(),
                    'expertSearch.sex' : $("#sex").val(),
                    'expertSearch.birthdayFrom' : $("#birthdayFrom").val(),
                    'expertSearch.birthdayTo' : $("#birthdayTo").val(),
                    'expertSearch.graduatedFrom' : $("#graduatedFrom").val(),
                    'expertSearch.topEducation' : $("#topEducation").val(),
                    'expertSearch.educationType' : $("#educationType").val(),
                    'expertSearch.subject' : $("#subject").val(),
                    'expertSearch.workUnit' : $("#workUnit").val(),
                    'expertSearch.title' : $("#title").val(),
                    'expertSearch.post' : $("#post").val(),
                    'expertSearch.skillsCert' : $("#skillsCert").val(),
                    'expertSearch.workPhone' : $("#workPhone").val(),
                    'expertSearch.cellPhone' : $("#cellPhone").val(),
                    'expertSearch.imAddress' : $("#imAddress").val(),
                    'expertSearch.mailAddress' : $("#mailAddress").val(),
                    'expertSearch.workAddress' : $("#workAddress").val(),
                    'expertSearch.address' : $("#address").val(),
                    'expertSearch.trainExperience' : $("#trainExperience").val(),
                    'expertSearch.workExperience' : $("#workExperience").val(),
                    'expertSearch.researchAchievement' : $("#researchAchievement").val(),
                    'expertSearch.socialWork' : $("#socialWork").val(),
                    'expertSearch.judgeExperience' : $("#judgeExperience").val(),
                    'expertSearch.remark' : $("#remark").val()
                };
                var postData = $("#expertSearch").jqGrid("getGridParam", "postData");
                $.extend(postData, expertSearch);
                $("#expertSearch").jqGrid("setGridParam", {
                    search: true,
                    datatype : "json"
                }).trigger("reloadGrid", [{page:1}]);

                $(this).dialog("close");
                return false;
            },
            取消 : function() {
                $(this).dialog("close");
                return false;
            }
        },
        close : function() {
            ;
        }
    });

    $('#keywordDetail').dialog({
        autoOpen : false,
        show : "slide",
        height : 200,
        width : 250,
        modal : true,
        buttons : {
            筛选 : function() {
                var sexCodeArray = getSexMatchCode($("#keyword").val());
                var educationCodeArray = getEducationMatchCode($("#keyword").val());
                var educationTypeCodeArray = getEducationTypeMatchCode($("#keyword").val());
                var expertSearch = {
                    'expertSearch.idNo' : $('#keyword').val(),
                    'expertSearch.name' : $('#keyword').val(),
                    'expertSearch.sex' : -1,
                    'expertSearch.sexCodes' : sexCodeArray.join(),
                    'expertSearch.birthdayFrom' : '',
                    'expertSearch.birthdayTo' : '',
                    'expertSearch.graduatedFrom' : $('#keyword').val(),
                    'expertSearch.topEducation' : -1,
                    'expertSearch.topEducationCodes' : educationCodeArray.join(),
                    'expertSearch.educationType' : -1,
                    'expertSearch.educationTypeCodes' : educationTypeCodeArray.join(),
                    'expertSearch.subject' : $('#keyword').val(),
                    'expertSearch.workUnit' : $('#keyword').val(),
                    'expertSearch.title' : $('#keyword').val(),
                    'expertSearch.post' : $('#keyword').val(),
                    'expertSearch.skillsCert' : $('#keyword').val(),
                    'expertSearch.workPhone' : $('#keyword').val(),
                    'expertSearch.cellPhone' : $('#keyword').val(),
                    'expertSearch.imAddress' : $('#keyword').val(),
                    'expertSearch.mailAddress' : $('#keyword').val(),
                    'expertSearch.workAddress' : $('#keyword').val(),
                    'expertSearch.address' : $('#keyword').val(),
                    'expertSearch.trainExperience' : $('#keyword').val(),
                    'expertSearch.workExperience' : $('#keyword').val(),
                    'expertSearch.researchAchievement' : $('#keyword').val(),
                    'expertSearch.socialWork' : $('#keyword').val(),
                    'expertSearch.judgeExperience' : $('#keyword').val(),
                    'expertSearch.remark' : $('#keyword').val(),
                    'expertSearch.isOr' : true
                };
                var postData = $("#expertSearch").jqGrid("getGridParam", "postData");
                $.extend(postData, expertSearch);
                $("#expertSearch").jqGrid("setGridParam", {
                    search: true,
                    datatype : "json"
                }).trigger("reloadGrid", [{page:1}]);

                $(this).dialog("close");
                return false;
            },
            解除筛选 : function() {
                var expertSearch = {
                    'expertSearch.idNo' : '',
                    'expertSearch.name' : '',
                    'expertSearch.sex' : -1,
                    'expertSearch.sexCodes' : '',
                    'expertSearch.birthdayFrom' : '',
                    'expertSearch.birthdayTo' : '',
                    'expertSearch.graduatedFrom' : '',
                    'expertSearch.topEducation' : -1,
                    'expertSearch.topEducationCodes' : '',
                    'expertSearch.educationType' : -1,
                    'expertSearch.educationTypeCodes' : '',
                    'expertSearch.subject' : '',
                    'expertSearch.workUnit' : '',
                    'expertSearch.title' : '',
                    'expertSearch.post' : '',
                    'expertSearch.skillsCert' : '',
                    'expertSearch.workPhone' : '',
                    'expertSearch.cellPhone' : '',
                    'expertSearch.imAddress' : '',
                    'expertSearch.mailAddress' : '',
                    'expertSearch.workAddress' : '',
                    'expertSearch.address' : '',
                    'expertSearch.trainExperience' : '',
                    'expertSearch.workExperience' : '',
                    'expertSearch.researchAchievement' : '',
                    'expertSearch.socialWork' : '',
                    'expertSearch.judgeExperience' : '',
                    'expertSearch.remark' : '',
                    'expertSearch.isOr' : true
                };
                var postData = $("#expertSearch").jqGrid("getGridParam", "postData");
                $.extend(postData, expertSearch);
                $("#expertSearch").jqGrid("setGridParam", {
                    search: true,
                    datatype : "json"
                }).trigger("reloadGrid", [{page:1}]);
                $(this).dialog("close");
                return false;
            },
            取消 : function() {
                $(this).dialog("close");
                return false;
            }
        },
        close : function() {
            ;
        }
    });
}

function toHistory(id) {
    $('#expertId').val(id);
    $('#rForm').attr("action", "showExpertCallHistory.action");
    $('#rForm').submit();
}

function toDetail(id) {
    $('#expertId').val(id);
    $('#rForm').attr("action", "showExpertDetail.action");
    $('#rForm').submit();
}
